package a_baseExample2;

import java.io.File;

import org.apache.commons.io.FileUtils;

import com.alibaba.fastjson.JSON;
import com.wang.template.json.JsonLoader;
import com.wang.template.json.JsonRender;
import com.wang.template.json.node.BaseNode;

import lombok.Data;

public class BaseExample2 {
	/**
	 * 数据源是对象
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		String jsonStr = FileUtils.readFileToString(new File(BaseExample2.class.getResource("json.json").getPath()),"UTF-8");
		Inner in = new Inner();
		in.setRetCode("00000");
		in.setRetMsg("服务执行成功"); 
		BaseNode node = JsonLoader.load(jsonStr);
		long start = System.currentTimeMillis();
		Object obj= JsonRender.render(node, in);
		 
		System.out.println("耗时" + (System.currentTimeMillis() - start) + JSON.toJSONString(obj, true));
	}
}

@Data
class Inner {
	private String retCode;
	private String retMsg;
}
